package com.test.jdk;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class InterfaceInner {

    /**
     * 无参
     */
    @Test
    public void test() {
        // 编写业务逻辑，并将业务逻辑作为参数传递给eat方法
        eat(() -> {
                    int a = 0;
                    for (int i = 0; i < 10; i++)
                        a += i;
                    System.out.println(a);
                }
        );
    }

    /**
     * 这里调用接口方法
     */
    private void eat(UserInterface c) {
        c.eat();
    }

    /**
     * 有参
     */
    @Test
    public void test1() {
        study(a -> a.forEach(System.out::println));
    }

    private void study(CustomInterface c) {
        List<String> list = Arrays.asList("a","b","c");
        c.eat(list);
    }
}
